<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class module extends CI_Controller {

	public function __construct()
	{
            parent::__construct();
            $this->load->model('common');            
            if(!$this->session->userdata('gcwgulberg_adminid'))
            {
                redirect('../admin/index.php/userlogin');
            }
            $this->load->library('form_validation');
            $this->load->library('upload');

        }
	public function index(){}

	public function track()
	{
            $seg3val = $this->uri->segment(3);
            if(!empty($seg3val))
            {
                $data['editdata'] = $this->common->get_track($seg3val);                
            }
            $data['track_list'] = $this->common->get_all_track();
            
            $this->form_validation->set_rules('bill_number', 'Bill Number', 'required');
            $this->form_validation->set_rules('origin', 'Origin', 'required');
            $this->form_validation->set_rules('destination', 'Destination', 'required');
            $this->form_validation->set_rules('container_id', 'Container no', 'required');
            if($this->form_validation->run() == FALSE){
                $this->load->view('adminheader');
                $this->load->view('leftmenu');
                $this->load->view('manage_track', $data);
                $this->load->view('adminfooter');
            }
            else{			
                $this->common->add_bill();
                redirect('../admin/index.php/module/track/');
            }	    
        }
        
        public function status()
	{
            $seg3val = $this->uri->segment(3);
            if(!empty($seg3val))
            {
                $data['editdata'] = $this->common->get_status($seg3val);                
            }
            $data['track_list'] = $this->common->get_all_track();
            $data['status_list'] = $this->common->get_all_status();
            
            $this->form_validation->set_rules('bill_number', 'Bill Number', 'required');
            $this->form_validation->set_rules('status', 'Status', 'required');
            $this->form_validation->set_rules('location', 'Location', 'required');
            if($this->form_validation->run() == FALSE){
                $this->load->view('adminheader');
                $this->load->view('leftmenu');
                $this->load->view('manage_bill_status', $data);
                $this->load->view('adminfooter');
            }
            else{			
                $this->common->add_bill_status();
                redirect('../admin/index.php/module/status/');
            }	    
        }
        
        public function del_track()
        {
			$bill_number = $this->uri->segment(3);			
			$this->db->query("delete from tbl_tracks where bill_number=$bill_number");
            $this->db->query("delete from tbl_status where bill_number=$bill_number");
            redirect('../admin/index.php/module/track/');
        }
}

?>